package com.imooc.netty.samples.$16;

import sun.misc.Cleaner;

/**
 * 注:要使用java8,若是java11找不到 `import sun.misc.Cleaner;`包
 * 可能jdk11中不在默认包含该类,需在pom中导入所需依赖
 */
public class CleanerTest
{
    public static void main(String[] args)
    {
        Object obj = new Object();
        Cleaner cleaner = Cleaner.create(obj, () -> {
            System.out.println("xxxxx");
        });

        Cleaner cleaner2 = Cleaner.create(obj, () -> {
            System.out.println("yyyyy");
        });
        //        cleaner.enqueue();
        //        cleaner2.enqueue();
        obj = null;
        System.gc();

    }
}
